<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.pptree.service.*"%>
<%@ page import="com.pptree.service.impl.*"%>
<%@ page import="com.pptree.util.*"%>
<%@ page import="com.pptree.vo.*"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>



<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">

<title>新闻发布系统前台首页</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="css/main.css" rel="stylesheet" type="text/css" />

<style type="text/css">
.side_list li span.numb {
	background: url(images/icp.jpg) -2px -39px;
	color: #fff;
}

.side_list li span.num {
	
    background: url(images/icp.jpg) -2px -71px;
    color: #fff;

}

span {
	width: 20px;
	text-align: center;
	line-height: 20px;
	height:20px;
	text-align: center;
	font-family: Arial;
	margin: 5px;
	display: inline-block;
}
.error{
	color:red;
	font-size:12px;
	font-weight: bold;
}
</style>
</head>

<body>
	<div id="header">
		<div id="top_login">
		
			<c:set value="${ not empty user}" var="islogin" scope="request"></c:set>
			
			<c:if test="${  islogin }">
				欢迎 ${user.realName} <a href="${pageContext.request.contextPath}/logout" onclick="return confirm('确定要登出吗？');">登出</a>
			</c:if>
			
			<c:if test="${ not islogin }">
				<form action="${pageContext.request.contextPath}/signin" method="post">
						<label for="username">登录名</label>
						<input type="text" name="username" id="username" class="login_input" required />
						<label for="password">密&#160;&#160;码</label> 
						<input type="password" name="password" id="password" class="login_input" required />
						<input type="submit" class="login_sub" value="登录" /> 
						<label class="error">${errorMsg}</label>
						<img src="images/friend_logo.gif" alt="login" id="friend_logo" />
					</form>
			</c:if>
			
			<%-- <c:choose>
				<c:when test="${ empty user}">
					<form action="${pageContext.request.contextPath}/signin" method="post">
						<label for="username">登录名</label>
						<input type="text" name="username" id="username" class="login_input" required />
						<label for="password">密&#160;&#160;码</label> 
						<input type="password" name="password" id="password" class="login_input" required />
						<input type="submit" class="login_sub" value="登录" /> 
						<label class="error">${errorMsg}</label>
						<img src="images/friend_logo.gif" alt="login" id="friend_logo" />
					</form>
				</c:when>
				<c:otherwise>
					欢迎 ${user.realName} <a href="${pageContext.request.contextPath}/logout" onclick="return confirm('确定要登出吗？');">登出</a>
				</c:otherwise>
			</c:choose> --%>
			
			
		</div>
		<div id="nav">
			<div id="logo">
				<img src="images/logo.jpg" alt="新闻中国" />
			</div>
			<div id="a_b01">
				<img src="images/a_b01.gif" alt="" />
			</div>
			<!--mainnav end-->
		</div>
	</div>
	<div id="container">
		<div class="sidebar">
			<h1>
				<img src="images/title_1.gif" alt="国内新闻" />
			</h1>
			<div class="side_list">
				<ul>
					<%
						NewsService newsService = new NewsServiceImpl();
					    List<News> newsList = newsService.findNewsTopNum(1, 8);
					    for(int i=0;i < newsList.size();i++) { 
					    	News news = newsList.get(i);
					    %>

					<li>
						<% if(i < 3 ) { %>
							<span class="numb"><%= (i+1) %></span>
						<% } else { %>
							<span class="num"><%= (i+1) %></span>
						<% } %>
					<a href="#" title="<%= news.getTitle() %>"><b><%= StringUtil.cutString(news.getTitle(),15) %></b></a></li>

					<% } %>

				</ul>
			</div>
			<h1>
				<img src="images/title_2.gif" alt="国际新闻" />
			</h1>
			<div class="side_list">
				<ul>

					<%
						
					    newsList = newsService.findNewsTopNum(2, 8);
					    for(int i=0;i < newsList.size();i++) { 
					    	News news = newsList.get(i);
					    %>

					<li>
						<% if(i < 3 ) { %>
							<span class="numb"><%= (i+1) %></span>
						<% } else { %>
							<span class="num"><%= (i+1) %></span>
						<% } %>
					<a href="#" title="<%= news.getTitle() %>"><b><%= StringUtil.cutString(news.getTitle(),15) %></b></a></li>

					<% } %>


				</ul>
			</div>
			<h1>
				<img src="images/title_3.gif" alt="娱乐新闻" />
			</h1>
			<div class="side_list">
				<ul>
					<%
					
					    newsList = newsService.findNewsTopNum(5, 8);
					    for(int i=0;i < newsList.size();i++) { 
					    	News news = newsList.get(i);
					    %>

					<li><% if(i < 3 ) { %>
							<span class="numb"><%= (i+1) %></span>
						<% } else { %>
							<span class="num"><%= (i+1) %></span>
						<% } %><a href="#" title="<%= news.getTitle() %>"><b><%= StringUtil.cutString(news.getTitle(),15) %></b></a></li>

					<% } %>

				</ul>
			</div>
		</div>



		<div class="main">
			<div class="class_type">
				<img src="images/class_type.gif" alt="新闻中心" />
			</div>
			<div class="content">
				<ul class="class_date">
					<%
						GenreService genreService = new GenreServiceImpl();
						List<Genre> categoryList = genreService.getAllCategories();
						request.setAttribute("categoryList", categoryList);
						
					%>
				
					<c:forEach items="${categoryList}" var="category" varStatus="vs">
						<c:if test="${vs.count % 11 == 1}">
							<li id='class_month'>
						</c:if>
							<a href="#"><b>${category.name}</b></a>
						<c:if test="${ vs.count % 11 == 0 }">
							</li>
						</c:if>
						<c:set scope="request" var="count" value="${vs.count}"></c:set>
					</c:forEach>
					
					<c:if test="${ count % 11 != 0 }">
						</li>
					</c:if>
				</ul>
				<ul class="classlist">
					<%
					    newsList = newsService.findNewsTopN(30);
					    request.setAttribute("newsList", newsList);
					%>
					<c:forEach items="${newsList}" var="news" varStatus="st">
						
						<li><a href="#" title="${ news.title }">${ news.title }</a><span><fmt:formatDate value="${news.createdate}" pattern="MM/dd"/></span></li>
						<c:if test="${ st.count % 5 == 0 }">
							<li class="space"></li>
						</c:if>
					</c:forEach>
				</ul>
			</div>
			<div class="picnews">
				<ul>
					<li><a href="#"><img src="images/Picture1.jpg" width="249"
							alt="" /> </a><a href="#">幻想中穿越时空</a></li>
					<li><a href="#"><img src="images/Picture2.jpg" width="249"
							alt="" /> </a><a href="#">国庆多变的发型</a></li>
					<li><a href="#"><img src="images/Picture3.jpg" width="249"
							alt="" /> </a><a href="#">新技术照亮都市</a></li>
					<li><a href="#"><img src="images/Picture4.jpg" width="249"
							alt="" /> </a><a href="#">群星闪耀红地毯</a></li>
				</ul>
			</div>
		</div>
	</div>
	<div id="friend">
		<h1 class="friend_t">
			<img src="images/friend_ico.gif" alt="合作伙伴" />
		</h1>
		<div class="friend_list">
			<ul>
				<li><a href="#">百度</a></li>
				<li><a href="#">谷歌</a></li>
				<li><a href="#">新浪</a></li>
				<li><a href="#">网易</a></li>
				<li><a href="#">搜狐</a></li>
				<li><a href="#">人人</a></li>
				<li><a href="#">中国政府网</a></li>
			</ul>
		</div>
	</div>
	<div id="footer">
		<p class="">
			24小时客户服务热线：010-68988888 &#160;&#160;&#160;&#160; <a href="#">常见问题解答</a>
			&#160;&#160;&#160;&#160; 新闻热线：010-627488888 <br />
			文明办网文明上网举报电话：010-627488888 &#160;&#160;&#160;&#160; 举报邮箱： <a href="#">jubao@jb-aptech.com.cn</a>
		</p>
		<p class="copyright">
			Copyright &copy; 1999-2009 News China gov, All Right Reserver <br />
			新闻中国 版权所有
		</p>
	</div>
</body>
</html>
